from collections import deque


class Solution:
    def removeDuplicates(self, s: str) -> str:
        st = []

        for tmp in s:
            if not st:
                st.append(tmp)
            elif st[-1] == tmp:
                st.pop()
            else:
                st.append(tmp)
        return "".join(st)

print(Solution().removeDuplicates("abbaca"))